package veating.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import veating.bean.City;
import veating.dao.CityDao;
import veating.service.Dbcp;

public class CityDaoImpl implements CityDao{
	@Override
	public List<City> findAllCity() {
		List<City> list = null;
		QueryRunner qr = new QueryRunner(Dbcp.getDataSource());
		try {
			String sql = "SELECT * FROM city ORDER BY cid DESC ";
			list = qr.query(sql, new BeanListHandler<City>(City.class));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}

}
